package com.j1903.controller;

import com.j1903.annotation.PassJwt;
import com.j1903.util.JsonResult;
import com.j1903.util.QiNiuUtil;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.UUID;

@RestController
@RequestMapping("/upload")
public class UploadFileController {
    @RequestMapping("/img")
    @PassJwt
    public JsonResult uploadImg(
            @RequestParam("file") MultipartFile file
    ){
        String fileName= null;
        //UploadFile.springbootSave(file,"d:\\springbootimages");
        try {

            fileName = new QiNiuUtil().upload(file.getInputStream());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new JsonResult(200, "上传成功", fileName);
    }
}
